package com.example.android.daos

import androidx.room.*
import com.example.android.models.MessageView

/**
 * @ClassName MessageViewDao
 * @Author Ryan Kamanri
 * @Date 2022/6/12
 * @Description
 **/
@Dao
interface MessageViewDao  {
    @Insert
    fun Insert(messageView : MessageView) : Long

    @Delete
    fun Delete(messageView : MessageView) : Unit

    @Update
    fun Update(messageView : MessageView) : Unit

    @Query("select * from messageview")
    fun SelectAll() : List<MessageView>

    @Query("select * from messageview where sendUserId = :id")
    fun SelectBySendUserID(id : Long) : List<MessageView>

    @Query("select * from messageview where receiveUserId = :id")
    fun SelectByReceiveID(id : Long) : List<MessageView>

    @Query("select * from messageview where sendUserId = :sendUserId and receiveUserId = :receiveUserId")
    fun SelectBySendUserIDAndReceiveID(sendUserId : Long, receiveUserId : Long) : List<MessageView>
}